<template>
  <div class="appcontainer">
    <!--中间的路由区域-->
    <keep-alive exclude="location mine">
      <router-view></router-view>
    </keep-alive>

    <!--底部 TAbbar 区域 -->
    <nav class="mui-bar mui-bar-tab" v-show="flag">
      <router-link class="mui-tab-item-llb" to="/home">
        <span class="mui-icon mui-icon-home"></span>
        <span class="mui-tab-label">首页</span>
      </router-link>
      <router-link class="mui-tab-item-llb" to="/store">
        <span class="mui-icon mui-icon-email"></span>
        <span class="mui-tab-label">门店</span>
      </router-link>
      <router-link class="mui-tab-item-llb" to="/action">
        <span class="mui-icon mui-icon-contact"></span>
        <span class="mui-tab-label">活动</span>
      </router-link>
      <router-link class="mui-tab-item-llb" to="/mine">
        <span class="mui-icon mui-icon-gear"></span>
        <span class="mui-tab-label">我的</span>
      </router-link>
    </nav>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: true
    };
  },
  created() {
    if (this.$route.path === "/home") {
      this.flag = true;
    } else if (this.$route.path === "/action") {
      this.flag = true;
    } else if (this.$route.path === "/store") {
      this.flag = true;
    } else if (this.$route.path === "/mine") {
      this.flag = true;
    } else {
      this.flag = false;
    }
    // if (this.$route.path === "/home" || "/action" || "/store" || "/mine") {
    //   this.flag = true;
    // } else {
    //   this.flag = false;
    // }
  },
  watch: {
    "$route.path": function(newVal) {
      if (newVal === "/home") {
        this.flag = true;
      } else if (newVal === "/action") {
        this.flag = true;
      } else if (newVal === "/store") {
        this.flag = true;
      } else if (newVal === "/mine") {
        this.flag = true;
      } else {
        this.flag = false;
      }
      // if (newVal === "/home" || "/action" || "/store" || "/mine") {
      //   this.flag = true;
      // } else {
      //   this.flag = false;
      // }
    }
  }
};
</script>


<style lang="scss" scoped>
.appcontainer {
  //padding-top: 40px;
  // width: 100%;
  height: 100%;
  overflow-x: hidden; //溢出隐藏（超出页面元素隐藏起来）
  padding-bottom: 50px;
}

//改类名  解决 tabbar 无法正常操作的问题
// 改类名，解决tabbar切换失败的问题
.mui-bar-tab .mui-tab-item-llb.mui-active {
  color: #007aff;
  // overflow: none;
  // position: relative;
  .mui-icon {
    // font-size: 40px;
    // // width: 40px;
    // // height: 40px;
    // top: -13px;
    // left: 27px;
    // display: flex;
    // position: relative;
  }
}
//调整tabbar图片大小所需
// .mui-bar .mui-icon {
//   font-size: 25px;
//   position: relative;
//   z-index: 20;
//   padding-top: 10px;
//   padding-bottom: 10px;
// }
.mui-bar-tab .mui-tab-item-llb {
  display: table-cell;
  overflow: hidden;
  width: 1%;
  height: 50px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #929292;
}
.mui-bar-tab .mui-tab-item-llb .mui-icon {
  top: 3px;
  width: 24px;
  height: 24px;
  padding-top: 0;
  padding-bottom: 0;
}
.mui-bar-tab .mui-tab-item-llb .mui-icon ~ .mui-tab-label {
  font-size: 11px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>
